var app = getApp();

Page({
    data: {
        index: 0,
        base: !1
    },
  onLoad: function (options) {
    console.log(77,options)
        wx.setNavigationBarColor({
            frontColor: "#ffffff",
            backgroundColor: wx.getStorageSync("color"),
            animation: {
                duration: 0,
                timingFunc: "easeIn"
            }
        }), this.reload();
    },
  queding: function (tz_id) {
    console.log(6666, tz_id)
    app.util.request({
      url: "entry/wxapp/sjdlogin",
      cachetime: "0",
      data: {
        user_id: wx.getStorageSync("users").id
      },
      success: function (e) {
        if (console.log(e), 0 == e.data) wx.showModal({
          title: "提示",
          content: "当前账号还未入驻",
          showCancel: !0,
          cancelText: "取消",
          confirmText: "确定",
          success: function (e) {
            wx.navigateTo({
              url: "../../settled/settled",
            });
           },
          fail: function (e) { },
          complete: function (e) { }
        }); else if ("1" == e.data.state) wx.showModal({
          title: "提示",
          content: "您的入驻申请正在后台审核，请耐心等待"
        }); else if ("2" == e.data.state) {
          wx.setStorageSync("store_info", e.data);
          e.data.user_id;
          wx.navigateTo({
            url: "../../logs/publish?store_id=" + e.data.id + "&fenlei=" + tz_id,
          });
          // wx.redirectTo({
          //   url: "../../logs/publish?store_id=" + e.data.id,
          //   success: function (e) { },
          //   fail: function (e) { },
          //   complete: function (e) { }
          // });
        } else "3" == e.data.state && wx.showModal({
          title: "提示",
          content: "您的入驻申请已被拒绝，请联系平台处理"
        });
      }
    });
  },
    reload: function(a) {
        var e = this, t = wx.getStorageSync("System");
        console.log(t);
        var n = wx.getStorageSync("url");
        e.setData({
            url: n,
            pt_name: t.pt_name,
            System: wx.getStorageSync("System")
        }), app.util.request({
            url: "entry/wxapp/types2",
            cachetime: "0",
            success: function(a) {
                console.log(a);
                var t = a.data;
                e.setData({
                    nav: t
                });
            }
        });
    },
    settled: function(a) {
        wx.navigateTo({
            url: "../../settled/settled",
            success: function(a) {},
            fail: function(a) {},
            complete: function(a) {}
        });
    },
    formid_one: function(a) {
        console.log("搜集第一个formid"), console.log(a), app.util.request({
            url: "entry/wxapp/SaveFormid",
            cachetime: "0",
            data: {
                user_id: wx.getStorageSync("users").id,
                form_id: a.detail.formId,
                openid: wx.getStorageSync("openid")
            },
            success: function(a) {}
        });
    },
    bindPickerChange: function(a) {
        console.log(a);
        var t = this, e = t.data.id, n = a.detail.value, o = t.data.nav[t.data.index].array[n];
        for (var i in t.data.nav[t.data.index].array) if (o == t.data.nav[t.data.index].arrays[i].name) var d = t.data.nav[t.data.index].arrays[i].id, r = t.data.nav[t.data.index].arrays[i].type_id, s = t.data.nav[t.data.index].money;
        console.log(t.data.nav[t.data.index]), wx.navigateTo({
            url: "../edit/edit?info=" + o + "&id=" + e + "&type_id=" + d + "&money=" + s + "&type2_id=" + r
        });
    },
    edit: function(a) {
        var t = this;
        console.log(66,a);
      var e = a.currentTarget.dataset.index, n = a.currentTarget.dataset.id, o = t.data.nav[e].money + "," + t.data.nav[e].money2, i = [], d = wx.getStorageSync("users").id, h = t.data.nav[e].sb_type;
      if(h==1){
        t.queding(n);
        // wx.navigateTo({
        //   url: "../../logs/publish?store_id=2"
        // });
      } else if(h == 0){
        console.log(o), app.util.request({
          url: "entry/wxapp/FtXz",
          cachetime: "0",
          data: {
            user_id: d
          },
          success: function (a) {
            console.log(a, d), "今天发帖次数已经超限!" == a.data ? wx.showModal({
              title: "提示",
              content: "今天发帖次数已经超限!"
            }) : app.util.request({
              url: "entry/wxapp/type2",
              cachetime: "0",
              data: {
                id: n
              },
              success: function (a) {
                console.log(a), 0 != a.data.length ? (a.data.map(function (a) {
                  var t;
                  t = a.name, i.push(t);
                }), console.log(i), t.setData({
                  array: i,
                  arrays: a.data,
                  base: !0,
                  type_id: n,
                  money: o
                })) : wx.navigateTo({
                  url: "../edit/edit?id=" + t.data.id + "&type_id=" + n + "&money=" + o + "&type2_id=0" + "&sb_type=" + h
                });
              }
            });
          }
        });
      }

    },
    cancel: function(a) {
        this.setData({
            base: !1
        });
    },
    selected: function(a) {
      var t = this, e = t.data.arrays, n = a.currentTarget.id, o = t.data.type_id, i = e[n].id, d = e[n].name, r = t.data.money;
        t.setData({
            base: !1
        }), wx.navigateTo({
          url: "../edit/edit?type2_id=" + i + "&type_id=" + o + "&money=" + r + "&info=" + d
        });
    },
    onReady: function() {},
    onShow: function() {
        wx.getSetting({
            success: function(a) {
                console.log(a), a.authSetting["scope.userInfo"] || (console.log("未授权过"), wx.switchTab({
                    url: "../../index/index"
                }));
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});